<template>
  <el-card shadow="navar">
    <el-row :gutter="15">
      <el-form ref="elForm" :model="formData" size="medium" label-width="120px">
        <el-col :span="24">
          <el-form-item label="用户名称" prop="memberName">
            <el-input
              v-model.trim="formData.memberName"
              :disabled="disabled"
              placeholder="暂无"
              show-word-limit
              clearable
              :style="{ width: 'calc(50% - 67px)' }"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="微信名称" prop="vxName">
            <el-input
              v-model.trim="formData.vxName"
              :disabled="disabled"
              placeholder="暂无"
              show-word-limit
              clearable
              :style="{ width: '100%' }"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="客户联系方式" prop="memberPhone">
            <el-input
              v-model.trim="formData.memberPhone"
              :disabled="disabled"
              placeholder="暂无"
              show-word-limit
              clearable
              :style="{ width: '100%' }"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="客户类型" prop="memberType">
            <el-select
              v-model.number="formData.memberType"
              :disabled="disabled"
              placeholder="暂无"
              clearable
              :style="{ width: '100%' }"
            >
              <el-option
                v-for="item in dict.type.coupon_memberType"
                :key="item.value"
                :label="item.label"
                :value="parseInt(item.value)"
              />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="手机型号" prop="phoneModel">
            <el-input
              v-model.trim="formData.phoneModel"
              :disabled="disabled"
              placeholder="暂无"
              show-word-limit
              clearable
              :style="{ width: '100%' }"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="客户优惠券状态" prop="memberCouponStatus">
            <el-select
              v-model.number="formData.memberCouponStatus"
              :disabled="disabled"
              placeholder="暂无"
              clearable
              :style="{ width: 'calc(50% - 67px)' }"
            >
              <el-option
                v-for="item in dict.type.coupon_memberCouponStatus"
                :key="item.value"
                :label="item.label"
                :value="parseInt(item.value)"
              />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="优惠券来源" prop="sourceType">
            <el-select
              v-model.number="formData.sourceType"
              :disabled="disabled"
              placeholder="暂无"
              clearable
              :style="{ width: 'calc(50% - 67px)' }"
            >
              <el-option
                v-for="item in dict.type.coupon_sourceType"
                :key="item.value"
                :label="item.label"
                :value="parseInt(item.value)"
              />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="优惠券领取时间" prop="distributedTime">
            <el-date-picker
              v-model.trim="formData.distributedTime"
              :disabled="disabled"
              type="datetime"
              placeholder="暂无"
              :style="{ width: '100%' }"
              value-format="yyyy-MM-dd HH:mm:ss"
            >
            </el-date-picker>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="优惠券有效时间" prop="validTime">
            <el-date-picker
              v-model.trim="formData.validTime"
              :disabled="disabled"
              type="datetime"
              placeholder="暂无"
              :style="{ width: '100%' }"
              value-format="yyyy-MM-dd HH:mm:ss"
            >
            </el-date-picker>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="业务类型" prop="businessName">
            <el-input
              v-model.trim="formData.businessName"
              :disabled="disabled"
              placeholder="暂无"
              show-word-limit
              clearable
              :style="{ width: 'calc(50% - 67px)' }"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="使用类型" prop="useTypeName">
            <el-input
              v-model.trim="formData.useTypeName"
              :disabled="disabled"
              placeholder="暂无"
              show-word-limit
              clearable
              :style="{ width: 'calc(50% - 67px)' }"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="适用项目类型" prop="useArea">
            <el-select
              v-model.number="formData.useArea"
              :disabled="disabled"
              placeholder="暂无"
              clearable
              :style="{ width: 'calc(50% - 67px)' }"
            >
              <el-option
                v-for="item in dict.type.coupon_useArea"
                :key="item.value"
                :label="item.label"
                :value="parseInt(item.value)"
              />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="指定项目名称" prop="serviceItems">
            <el-input
              v-model.trim="formData.serviceItems"
              :disabled="disabled"
              placeholder="暂无"
              show-word-limit
              clearable
              :style="{ width: 'calc(50% - 67px)' }"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="优惠券名称" prop="couponName">
            <el-input
              v-model.trim="formData.couponName"
              :disabled="disabled"
              placeholder="暂无"
              :maxlength="50"
              show-word-limit
              clearable
              :style="{ width: 'calc(50% - 67px)' }"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="优惠券开始时间" prop="sendTimeStart">
            <el-date-picker
              v-model.trim="formData.sendTimeStart"
              :disabled="disabled"
              type="datetime"
              placeholder="暂无"
              value-format="yyyy-MM-dd HH:mm:ss"
              :style="{ width: '100%' }"
            >
            </el-date-picker>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="优惠券结束时间" prop="sendTimeEnd">
            <el-date-picker
              v-model.trim="formData.sendTimeEnd"
              :disabled="disabled"
              type="datetime"
              placeholder="暂无"
              value-format="yyyy-MM-dd HH:mm:ss"
              :style="{ width: '100%' }"
            >
            </el-date-picker>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="优惠信息" prop="preferentialInfo">
            <el-input
              v-model.trim="formData.preferentialInfo"
              :disabled="disabled"
              placeholder="暂无"
              clearable
              :style="{ width: 'calc(50% - 67px)' }"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item prop="useTime" label="使用有效期">
            <el-input
              v-model.trim="formData.useTime"
              :disabled="disabled"
              placeholder="暂无"
              clearable
              :style="{ width: '100%' }"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="是否允许转赠" prop="isTurn">
            <el-radio-group
              v-model="formData.isTurn"
              :style="{ width: '100%' }"
            >
              <el-radio
                v-for="item in dict.type.coupon_is_turn"
                :disabled="disabled"
                :key="item.value"
                :label="parseInt(item.value)"
                >{{ item.label }}</el-radio
              >
            </el-radio-group>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="适用单位类型" prop="applicableUnitType">
            <el-radio-group v-model="formData.applicableUnitType">
              <el-radio
                v-for="item in dict.type.coupon_applicableUnitType"
                :disabled="disabled"
                :key="item.value"
                :label="parseInt(item.value)"
                >{{ item.label }}</el-radio
              >
            </el-radio-group>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="适用单位名称" prop="applicableUnit">
            <el-input
              v-model.trim="formData.applicableUnit"
              :disabled="disabled"
              placeholder="暂无"
              show-word-limit
              clearable
              :style="{ width: 'calc(50% - 67px)' }"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="所属租户" prop="tenantName">
            <el-input
              v-model.trim="formData.tenantName"
              :disabled="disabled"
              placeholder="暂无"
              show-word-limit
              clearable
              :style="{ width: 'calc(50% - 67px)' }"
            ></el-input>
          </el-form-item>
        </el-col>
        <!-- <el-col :span="12">
          <el-form-item label="优惠券类别" prop="category">
            <el-select
              v-model="formData.category"
              :disabled="disabled"
              placeholder="暂无"
              clearable
              size="small"
              :style="{ width: '100%' }"
            >
              <el-option
                v-for="item in dict.type.coupon_type"
                :key="item.value"
                :label="item.label"
                :value="parseInt(item.value)"
              />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="总库存" prop="sendTotal">
            <el-input
              v-model.trim="formData.sendTotal"
              :disabled="disabled"
              placeholder="暂无"
              show-word-limit
              clearable
              :style="{ width: '100%' }"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="发送节点名称" prop="distributedNode">
            <el-input
              v-model.trim="formData.distributedNode"
              :disabled="disabled"
              placeholder="暂无"
              show-word-limit
              clearable
              :style="{ width: '100%' }"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="优惠券状态" prop="couponStatus">
            <el-select
              v-model="formData.couponStatus"
              placeholder="暂无"
              clearable
              :disabled="disabled"
              size="small"
              :style="{ width: '100%' }"
            >
              <el-option
                v-for="item in dict.type.coupon_memberCouponStatus"
                :key="item.value"
                :label="item.label"
                :value="parseInt(item.value)"
              />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="创建人" prop="userName">
            <el-input
              v-model.trim="formData.userName"
              :disabled="disabled"
              placeholder="暂无"
              show-word-limit
              clearable
              :style="{ width: '100%' }"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="已发放" prop="issued">
            <el-input
              v-model.trim="formData.issued"
              :disabled="disabled"
              placeholder="暂无"
              show-word-limit
              clearable
              :style="{ width: '100%' }"
            ></el-input>
          </el-form-item>
        </el-col> -->
        <el-col :span="24">
          <el-form-item size="large" :style="{ textAlign: 'center' }">
            <el-button @click="goBack">取消</el-button>
          </el-form-item>
        </el-col>
      </el-form>
    </el-row>
  </el-card>
</template>

<script>
import { getMemberById } from '@/api/coupon/member'
export default {
  dicts: [
    'coupon_type',
    'coupon_use_time_type',
    'coupon_memberCouponStatus',
    'coupon_is_turn',
    'coupon_useArea',
    'coupon_applicableUnitType',
    'coupon_memberType',
    'coupon_sourceType',
  ],
  data() {
    return {
      disabled: true,
      isShowAddGoods: false,
      formData: {
        couponName: null,
        category: null,
        preferentialInfo: null,
        termTime: '',
        useTime: '',
        useTimeType: 1,
        useTypeName: '',
        couponStatus: null,
        isTurn: null,
        sendTimeStart: null,
        sendTimeEnd: null,
        tenantName: null,
        userName: null,
        businessName: null,
        useArea: null,
        serviceItems: null,
        sendTotal: null,
        issued: null,
        applicableUnitType: null,
        applicableUnit: null,
        distributedNode: null,
        memberName: null,
        vxUrl: null,
        vxName: null,
        memberPhone: null,
        memberType: null,
        memberCouponStatus: null,
        distributedTime: null,
        validTime: null,
        phoneModel: null,
      },
    }
  },
  created() {
    this.handleInit()
  },
  mounted() {},
  methods: {
    async handleInit() {
      await getMemberById({ id: this.$route.params.id }).then((res) => {
        this.formData = res.data
      })
    },
    goBack() {
      this.$router.go(-1) // 返回
      //关闭子页面
      this.$store.state.tagsView.visitedViews.splice(
        this.$store.state.tagsView.visitedViews.findIndex(
          (item) => item.path === this.$route.path
        ),
        1
      )
      this.$router.push(
        this.$store.state.tagsView.visitedViews[
          this.$store.state.tagsView.visitedViews.length - 1
        ].path
      )
    },
  },
}
</script>
